package com.hopes.bizz.risk.transfer.converter;

import com.hopes.bizz.risk.hid.entity.RiskHidHiddenDangerEntity;
import com.hopes.bizz.risk.transfer.bean.dto.RiskDangerInvestigationDto;
import com.hopes.bizz.risk.transfer.converter.expression.CommonExp;
import com.hopes.bizz.risk.transfer.converter.expression.RiskHidExp;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(uses = {CommonExp.class, RiskHidExp.class})
public interface RiskDangerInvestigationConverter {

    RiskDangerInvestigationConverter INSTANCE = Mappers.getMapper(RiskDangerInvestigationConverter.class);

    @Mapping(target = "uid", source = "id")
    @Mapping(target = "delFlag", source = "deleted", defaultValue = "0")
    @Mapping(target = "createTime", source = "createDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "createBy", source = "createBy")
    @Mapping(target = "updateTime", source = "updateDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "updateBy", source = "updateBy")
    @Mapping(target = "hidName", source = "dangerName")
    @Mapping(target = "hidLevel", source = "dangerLevel", qualifiedByName = "integerConverter")
    @Mapping(target = "hidSource", source = "dangerSrc", qualifiedByName = "hidSource")
    @Mapping(target = "correctiveWay", source = "dangerManageType", qualifiedByName = "integerConverter")
    @Mapping(target = "hidContent", source = "dangerDesc")
    @Mapping(target = "hidReason", source = "dangerReason")
    @Mapping(target = "correctiveDesc", source = "controlMeasures")
    @Mapping(target = "cost", source = "cost")
    @Mapping(target = "correctiveDeadline", source = "dangerManageDeadline", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "hidStatus", source = "dangerState" , qualifiedByName = "integerConverter")
    @Mapping(target = "hidType", source = "hazardDangerType" , qualifiedByName = "hidType")
    @Mapping(target = "hidCategory", source = "hazardCategory", qualifiedByName = "integerConverter")
    @Mapping(target = "reportUser", source = "registrant")
    @Mapping(target = "reportDate", source = "registTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "principal", source = "liablePerson")
    @Mapping(target = "checkUser", source = "checkAcceptPerson")
    @Mapping(target = "checkDesc", source = "checkAcceptComment")
    @Mapping(target = "checkTime", source = "checkAcceptTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @BeanMapping(ignoreByDefault = true)
    RiskHidHiddenDangerEntity toEntity(RiskDangerInvestigationDto riskDangerInvestigationDto);
}
